package com.melhoramigo;

import android.annotation.SuppressLint;
import android.app.Fragment;
import android.content.SharedPreferences;
import android.os.Bundle;
import android.preference.PreferenceManager;
import android.text.Html;
import android.view.LayoutInflater;
import android.view.View;
import android.view.View.OnClickListener;
import android.view.ViewGroup;
import android.widget.Button;
import android.widget.TextView;
import android.widget.Toast;

@SuppressLint("NewApi")
public class HomeFragment extends Fragment {
	
	TextView txtBemVindo;
    Button btMelhorAmigo;
    Button btLogin;
	
	@Override
    public View onCreateView(LayoutInflater inflater, ViewGroup container,
            Bundle savedInstanceState) {
 
        View rootView = inflater.inflate(R.layout.fragment_home, container, false);
         
        txtBemVindo = (TextView) rootView.findViewById(R.id.txtBemVindo);
        btMelhorAmigo = (Button) rootView.findViewById(R.id.btMelhorAmigo);
        btLogin = (Button) rootView.findViewById(R.id.btLogin);
        
        String bemvindo = "<font size='5'>BEM VINDO, </font>";
        String amigo = "<font size='5'><b>AMIGO!</b></font>";
        txtBemVindo.setText(Html.fromHtml(bemvindo + amigo));
        
        btMelhorAmigo.setOnClickListener(new OnClickListener() {
			
			@Override
			public void onClick(View arg0) {
				// Create new fragment and transaction
				Fragment newFragment = new AdocaoFragment();
				android.app.FragmentTransaction transaction = getFragmentManager().beginTransaction();

				// Replace whatever is in the fragment_container view with this fragment,
				// and add the transaction to the back stack
				transaction.replace(R.id.frame_container, newFragment);
				transaction.addToBackStack(null);

				// Commit the transaction
				transaction.commit();
			}
		});
        
        btLogin.setOnClickListener(new OnClickListener() {
			
  			@Override
  			public void onClick(View arg0) {
  				// Create new fragment and transaction
  				Fragment newFragment = new LoginFragment();
  				android.app.FragmentTransaction transaction = getFragmentManager().beginTransaction();

  				// Replace whatever is in the fragment_container view with this fragment,
  				// and add the transaction to the back stack
  				transaction.replace(R.id.frame_container, newFragment);
  				transaction.addToBackStack(null);

  				// Commit the transaction
  				transaction.commit();
  			}
  		});
        
        return rootView;
    }
}
